home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / atoib.c < prev    next >
Text File  |  1980-01-01  |  640b  |  21 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. /*
  3. ** atoib(s,b) - Convert s to "unsigned" integer in base b.
  4. **              NOTE: This is a non-standard function.
  5. */
  6.   static int n, digit;
  7.  
  8. atoib(s, b) char *s; int b; {
  9.   n = 0;
  10.   while(isspace(*s)) ++s;
  11.   while((digit = (127 & *s++)) >= '0') {
  12.     if(digit >= 'a')      digit -= 87;
  13.     else if(digit >= 'A') digit -= 55;
  14.     else                  digit -= '0';
  15.     if(digit >= b) break;
  16.     n = b * n + digit;
  17.     }
  18.   return (n);
  19.   }
  20.  
  21.